package vfs.obj.association.impl;

import java.sql.Connection;
import vfs.obj.association.VFSAssociationFactory;
import vfs.obj.association.VFSNodeOwnedByUser;
import vfs.obj.association.VFSNodeReadableByGroup;
import vfs.obj.association.VFSNodeToNodeType;
import vfs.obj.association.VFSNodeToParent;
import vfs.obj.association.VFSNodeWritableByGroup;
import vfs.obj.association.VFSPath;
import vfs.obj.association.VFSUserToGroup;
import vfs.obj.association.VFSUserToHomeDirectory;

/**
 * The VFSAssociationFactory creates instances of association
 * manipulators in the virtual folder system. Each type of association 
 * manipulator has addition, modification, removal, and querying 
 * methods for the type of association it represents.
 *
 * @author Matthew Eavenson <durandal@uga.edu>
 */
public class VFSAssociationFactoryImpl implements VFSAssociationFactory{

    private Connection conn;
    
    public VFSAssociationFactoryImpl(Connection conn){
        this.conn = conn;
    }
    
    /**
     * Returns a manipulator capable of manipulating the ownership
     * relationship between Nodes and Users.
     * 
     * @return an association manipulator
     */
    @Override
    public VFSNodeOwnedByUser getNodeOwnedByUser() {
        return new VFSNodeOwnedByUserImpl(conn);
    }

    /**
     * Returns a manipulator capable of manipulating the "readable by" 
     * relationship between Nodes and Groups.
     * 
     * @return an association manipulator
     */
    @Override
    public VFSNodeReadableByGroup getNodeReadableByGroup() {
        return new VFSNodeReadableByGroupImpl(conn);
    }
    
    /**
     * Returns a manipulator capable of manipulating the "writable by"
     * relationship between Nodes and Groups.
     * 
     * @return an association manipulator
     */
    @Override
    public VFSNodeWritableByGroup getNodeWritableByGroup() {
        return new VFSNodeWritableByGroupImpl(conn);
    }

    /**
     * Returns a manipulator capable of manipulating the "has type"
     * relationship between Nodes and Node types.
     * 
     * @return an association manipulator
     */
    @Override
    public VFSNodeToNodeType getNodeToNodeType() {
        return new VFSNodeToNodeTypeImpl(conn);
    }

    /**
     * Returns a manipulator capable of manipulating the "has parent"
     * relationship between Nodes and other Nodes.
     * 
     * @return an association manipulator
     */
    @Override
    public VFSNodeToParent getNodeToParent() {
        return new VFSNodeToParentImpl(conn);
    }

    /**
     * Returns a manipulator capable of manipulating the path
     * relationship between Nodes and their ancestors and descendants.
     * 
     * @return an association manipulator
     */
    @Override
    public VFSPath getPath() {
        return new VFSPathImpl(conn);
    }

    /**
     * Returns a manipulator capable of manipulating the "member of"
     * relationship between Users and Groups.
     * 
     * @return an association manipulator
     */
    @Override
    public VFSUserToGroup getUserToGroup() {
        return new VFSUserToGroupImpl(conn);
    }

    /**
     * Returns a manipulator capable of manipulating the "home directory"
     * relationship between Users and Nodes.
     * 
     * @return an association manipulator
     */
    @Override
    public VFSUserToHomeDirectory getUserToHomeDirectory() {
        return new VFSUserToHomeDirectoryImpl(conn);
    }
    
}
